<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>医院管理</title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/static/css/style1.css" />
    <link rel="icon" href="${pageContext.request.contextPath}/static/img/favicon.ico"  type="image/x-icon" />
    <link href="/static/js/laypage/skin/laypage.css" />
    <link href="${pageContext.request.contextPath}/static/js/laypage/skin/laypage.css" rel="stylesheet"/>
    　<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/laypage.js"></script>
    <script type="text/javascript" src="/static/js/laypage.js"></script>
    <link rel="stylesheet" type="text/css"
          href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" />
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/js/bootbox.min.js"></script>
    <style>
        .page {
            font-family: Arial, "楷体";
            font-size: 15px;
            line-height: 26px;
            color: #000000;
            height: 40px;
            margin-top: -15px;
            background-color: #EEF6FF;
            margin-right: 0;
        }


        .page td {
            padding-right: 10px;
            padding-left: 10px;
        }

        .page select {
            font-family: Arial, "楷体";
            font-size: 12px;
            color: #000000;
            line-height: 18px;
            border: 1.5px solid #5084BB;
        }
    </style>
</head>
<body>

<div class="box">
    <!-- 		<div class="title">后台管理用户信息表</div> -->
    <div class="content">
        <!--搜索输入框及查询、重置按钮-->
        <form action="/hospital/hospitalBy" method="post">
        <div class="container content_width">
            <div class="person_search">
                <div class="search_input">
                    <div class="input-group mb-3">
                        <span>根据关键字查询：</span> <input id="text" type="text" name="text"
                                                 class="form-control" placeholder="请输入关键字" value="">
                    </div>
                </div>

                <div class="search_input">

                    <button class="btn btn-primary search_btn" type="submit"
                            id="search_btn" >查询</button>

                    <button class="btn btn-primary search_btn" type="button"
                            id="back_btn">重置</button>
                </div>
            </div>
            <div class="line"></div>
        </div>
        </form>
        <!--添加按钮及bootstrap的模态框-->
        <div class="export">
            <button id="new_add" type="button" class="btn btn-primary btn-sm"
                    onclick="openwin()">
                <img src="/static/image/add_two.png" /> <span>添加</span>
            </button>
        </div>
        <!--表格列表-->
        <table id="tb" class="table">
            <thead>
            <tr>
                <td>id编号</td>
                <td>医院名字</td>
                <td>医院地址</td>
                <td>所属分区</td>
                <td>操作</td>
            </tr>
            </thead>
            <tbody id="show_tbody">
            <c:forEach items="${hospital}" var="h">
                <tr>
                    <td >${h.hospital_id}</td>
                    <td >${h.hospital_name}</td>
                    <td >${h.hospital_site}</td>
                    <td >${h.area_name}</td>
                    <td><div class="edit2">
                        <span id ="edit1" class="edit1" data-toggle="modal" data-target="#renyuan1" style="color:#479eff;cursor: pointer;" onclick="doHospitalModify(${h.hospital_id})">编辑</span>
                        <div class="modal fade" id="renyuan1">
                            <div class="modal-dialog modal-lg modal_position">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h4 class="modal-title">编辑</h4>
                                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    </div>
                                    <form id="form2" name="form2" action="/hospital/hospitalUpdate" >
                                        <div class="modal-body">
                                            <table id="xztb" class="table" >
                                                <tbody>
                                                <tr>
                                                    <td class="tb_bg"><label for=""><font
                                                            style="font-size: 14px; color: red;">*</font>医院ID：</label></td>
                                                    <td><input class="hospital_id" type="text"
                                                               name="hospital_id" id="hospital_id" value="${hospital_id }"/></td>
                                                </tr>
                                                <tr>
                                                    <td class="tb_bg"><label for=""><font
                                                            style="font-size: 14px; color: red;">*</font>医院名字：</label></td>
                                                    <td><input class="hospital_name" type="text"
                                                               name="hospital_name" id="hospital_name" value="${hospital_name }"/></td>
                                                </tr>
                                                <tr>
                                                    <td class="tb_bg"><label for=""><font
                                                            style="font-size: 14px; color: red;">*</font>医院地址</label></td>
                                                    <td><input class="hospital_site" type="text"
                                                               name="hospital_site" id="hospital_site" value="${hospital_site }"/></td>
                                                </tr>
                                                <tr>
                                                    <td class="tb_bg"><label for=""><font
                                                            style="font-size: 14px; color: red;">*</font>医院地区</label></td>
                                                    <td><input type="text" name="hospital_area" id="hospital_area" value="${hospital_area }"/></td>
                                                </tr>

                                                </tbody>
                                            </table>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-secondary"
                                                        data-dismiss="modal" style="background: white">取消</button>
                                                <button id="ad_btn" type="submit" class="btn btn-secondary" >确定</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div><a href="/hospital/hospitalDelete?id=${h.hospital_id}">删除</a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>

        <table width="100%" border="0" align="center" cellpadding="0"
               cellspacing="0" class="page">
            <tr>
                <td width="50%" align="left">共有&nbsp;${counttotal }&nbsp;条记录，<span
                        style="font-family: 楷体; font-size: 15px; color: black">第</span><span
                        style="font-family: 楷体; font-size: 15px; color: black">
						${pagecurrent }/${pages } </span><span
                        style="font-family: 楷体; font-size: 15px; color: black;">页</span></td>
                <td width="50%" align="right"><a href="/hospital/hospital/1">首页</a>
                    <a href="/hospital/hospital/${pagecurrent-1<=1?1:pagecurrent-1}">上一页</a>
                    <a
                            href="/hospital/hospital/${pagecurrent+1>=pages?pages:pagecurrent+1}">下一页</a>
                    <a href="/hospital/hospital/${pages}">末页&nbsp;</a>&nbsp;跳转到 <select
                            name="select2" onchange="changePage(this)">
                        <c:forEach begin="1" end="${pages }" step="1" var="i">
                            <option value="${i}" ${i==pagecurrent?"selected":"" }>${i
                                    }</option>
                        </c:forEach>
                    </select></td>
            </tr>
        </table>
        <script>
            //定义全局变量记录页码信息

            <%--var globalDate = {};--%>
            <%--//1页显示两条数据--%>
            <%--globalDate.pageSize=${pagesize};--%>

            <%--$(function () {--%>
            <%--    // globalDate.pageNum=1;--%>
            <%--    //查询数据--%>
            <%--    layer.alert('内容', {--%>
            <%--        icon: 1,--%>
            <%--        skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅--%>
            <%--    })--%>

            <%--    search();--%>

            <%--});--%>

            <%--//查询数据--%>
            <%--function search() {--%>
            <%--    var str = "";--%>


            <%--                var page = ${pages};  //总页数--%>
            <%--                var curr =${pagecurrent};    //当前页--%>
            <%--                var size= ${pagesize};--%>

            <%--                laypage({--%>
            <%--                    cont: 'doctorDiv',  //分页需要显示的地方--%>
            <%--                    pages: page,    //总页数--%>
            <%--                    curr: curr,     //当前页--%>
            <%--                    groups: size,//连续显示分页数--%>
            <%--                    skip: true,     //是否开启跳页--%>
            <%--                    first: '首页',--%>
            <%--                    last: '尾页',--%>
            <%--                    skin: 'molv',   //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00--%>
            <%--                    prev: '<', //若不显示，设置false即可--%>
            <%--                    next: '>', //若不显示，设置false即可--%>
            <%--                    jump: function (e, first) { //触发分页后的回调--%>
            <%--                        if (!first) { //一定要加此判断，否则初始时会无限刷新--%>
            <%--                            // globalDate.pageNum = e.curr;--%>
            <%--                            // search(globalDate);--%>

            <%--                            window.location="/hello/roles/"+e.curr;--%>
            <%--                        }--%>
            <%--                    }--%>
            <%--                });--%>
            <%--    };--%>
            function openwin() {
                window.open('/insertHospital.jsp', '新增', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
            }
            function changePage(th) {
                <%--					alert(th.value+"&word=${param.word}");--%>
                window.location="/hospital/hospital/"+th.value;
            }

            function doHospitalModify(hospital_id) {
                var data={
                    "hospital_id":hospital_id

                }
                $.ajax({
                    url:"/hospital/hospitalById",
                    type : "post",
                    data: JSON.stringify(data),
                    success:function (hospital) {
                        $("#hospital_id").val(hospital.hospital_id);
                        $("#hospital_name").val(hospital.hospital_name);
                        $("#hospital_site").val(hospital.hospital_site);
                        $("#hospital_area").val(hospital.hospital_area);
                    },
                    dataType: "json",
                    contentType: "application/json"
                })
            }

        </script>
    </div>
</div>

<script src="/static/js/mejs1.js"></script>
</body>
</html>
